package com.aier.controller.login;


import com.aier.bean.common.CommonResult;
import com.aier.bean.staff.StaffInfo;
import com.aier.service.rights.StaffInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/***
 * 登录功能
 */

@Controller
@CrossOrigin
public class LoginController {
    @Autowired
    private StaffInfoService staffInfoService;

    @RequestMapping("/login")
    @ResponseBody
    public CommonResult login(@RequestBody Map<String,String> map){
        String username = map.get("username");
        String password = map.get("password");
        StaffInfo staffInfo = staffInfoService.getStaffInfoByAccountAndPsd(username, password);
        return CommonResult.success(staffInfo);
    }
}
